#include "mainwindow.h"
#include "./ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->CmdSelector = new CmdSelect(ui->cmd_config_widget);
    ui->cmd_config_widget->layout()->addWidget(this->CmdSelector);
    this->load_cmd_list();
    ui->cmd_config_widget->layout()->setAlignment(Qt::AlignTop);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_button_run_clicked()
{

}

void MainWindow::load_cmd_list()
{
    std::vector<cmd_param_t> in;
    std::vector<cmd_param_t> out;
    cmd_param_t param;
    param.name = "EN";
    param.type = PARAM_TYPE_BOOL;
    param.is_array = false;
    in.push_back(std::move(param));

    param.name = "SPEED";
    param.type = PARAM_TYPE_LREAL;
    param.is_array = false;
    in.push_back(std::move(param));

    param.name = "S";
    param.type = PARAM_TYPE_LREAL;
    param.is_array = false;
    in.push_back(std::move(param));

    param.name = "EN";
    param.type = PARAM_TYPE_BOOL;
    param.is_array = false;
    out.push_back(std::move(param));

    param.name = "SPEED";
    param.type = PARAM_TYPE_LREAL;
    param.is_array = false;
    out.push_back(std::move(param));

    param.name = "S";
    param.type = PARAM_TYPE_LREAL;
    param.is_array = false;
    out.push_back(std::move(param));

    cmd_info* info = new cmd_info("MC_CMD1", in, out);
    this->CmdSelector->cmd_info_list.push_back(*info);
    delete info;
    info = new cmd_info("MC_CMD2", in, out);
    this->CmdSelector->cmd_info_list.push_back(*info);
    delete info;
    info = new cmd_info("MC_CMD3", in, out);
    this->CmdSelector->cmd_info_list.push_back(*info);
    delete info;
}
